In system software version 7.0 and later, you can manipulate temporary memory with three routines that are counterparts to other Memory Manager routines. The TempNewHandle function allocates a new block of relocatable memory, the TempFreeMem function returns the total amount of free memory available for temporary allocation, and the TempMaxMem function compacts the heap zone and returns the size of the largest contiguous block available for temporary allocation.
You should not call any of these memory-allocation routines at interrupt time.<36pt>
To allocate a new relocatable block of temporary memory, call the TempNewHandle function after making sure that there is enough free space to satisfy the request.
FUNCTION TempNewHandle (logicalSize: Size;
VAR resultCode: OSErr): Handle;
The TempNewHandle function returns a handle to a block of size logicalSize . If it cannot allocate a block of that size, the function returns NIL . Before you use the returned handle, make sure its value is not NIL .
To find out the total amount of memory available for temporary allocation, use the TempFreeMem function.
FUNCTION TempFreeMem: LongInt;
The TempFreeMem function returns the total amount of free temporary memory that you could allocate by calling TempNewHandle . The returned value is the total number of free bytes. Because these bytes might be dispersed throughout memory, it is ordinarily not possible to allocate a single relocatable block of that size.
To find the size of the largest contiguous block available for temporary allocation, use the TempMaxMem function.
FUNCTION TempMaxMem (VAR grow: Size): Size;
The TempMaxMem function compacts the current heap zone and returns the size of the largest contiguous block available for temporary allocation.